import random
import datetime
import sys
#sys.path.append("C:\\learning\\OpenCV\\MyDemo")
sys.path.append("..")
from entity import  organizations as o

#随机生成长度为len的数字
def randomNumber(len):
    return str(random.randint(1,9)).join(random.sample("1234567890",len-1))

#随机生成与特征码长度相等的数字
def randomCode():
    return randomNumber(o.CODE_LEN)

#校验时间格式
def valid_time(str):
    try:
        datetime.datetime.strptime(str,"%H:%M:%S")
        return True
    except:
        return False

#校验年月格式
def valid_year_month(str):
    try:
        datetime.datetime.strptime(str,"%Y-%M")
        return True
    except:
        return False

#校验日期格式
def valid_data(date):
    try:
        datetime.datetime.strptime(date,"%Y-%M-%d")
        return True
    except:
        return False

